var orgTree, orgDropDownTree, setting, dropDownSetting;
var zNodes = [];
setting = {
    checkable: false,
    async: true,
    asyncUrl: "org_getMenuTree.action", //获取节点数据的URL地址
    asyncParam: ["name", "id"], //获取节点数据时，必须的数据名称，例如：id、name
    callback: { //        asyncSuccess: zTreeOnAsyncSuccess,
        //        asyncError: zTreeOnAsyncError
    }
};
dropDownSetting = {
    checkable: false,
    async: true,
    asyncUrl: "org_getMenuTree.action", //获取节点数据的URL地址
    asyncParam: ["name", "id"], //获取节点数据时，必须的数据名称，例如：id、name
    callback: {
        click: dropDownTreeOnClick
    }
};
//加载树
function refreshTree(asyncUrl){
	setting.asyncUrl = templateRoot + asyncUrl;
	dropDownSetting.asyncUrl = templateRoot + asyncUrl;
    orgTree = $("#orgTree").zTree(setting, zNodes);
    orgDropDownTree = $("#dropdownMenu").zTree(dropDownSetting, zNodes);
}

//显示下拉框树
function showMenu(){
    var parentName = $("#parentName");
    var parentNameOffset = parentName.offset();
    $("#DropdownMenuBackground").css({
        left: parentNameOffset.left + "px",
        top: parentNameOffset.top + parentName.outerHeight() + "px"
    }).slideDown("slow");
}

//隐藏下拉框树
function hideMenu(){
    $("#DropdownMenuBackground").fadeOut("fast");
}

//dropdown树点击事件--给parentName文本框和parentId隐藏域赋值
function dropDownTreeOnClick(event, treeId, treeNode){
    if (treeNode) {
        var parentName = $("#parentName");
        var parentId = $("#parentId");
        parentName.attr("value", treeNode.name);
        parentId.attr("value", treeNode.id);
        hideMenu();
    }
}